function Drag(sel){
	if(!sel) return;
	if(typeof sel != "string") return;
	//	eles属性记录所有选择的元素
	this.eles = document.querySelectorAll(sel);
	//	_this:新创建出来的Drag对象
	var _this = this;
	
	for(var i = 0;i < this.eles.length;i++){
		//	记录上一次形变的位置
		this.eles[i].x = 0;
		this.eles[i].y = 0;
		this.eles[i].onmousedown = function(ev)
		{
			//	记录当前点击的元素
			_this.currentEle = this;
			_this.mouseDown.call(_this,ev);
			return false;
		};
		this.eles[i].oncontextmenu = function(ev)
		{
			return false;
		};
	}
	
}
Drag.prototype = {
	constructor:Drag,
	mouseDown:function(ev){
		ev = ev || event;
		console.log(this);
		//	记录触摸点的位置
		this.currentEle.disX = ev.clientX;
		this.currentEle.disY = ev.clientY;
		var _this = this;
		//	绑定鼠标移动事件
		document.onmousemove = function(ev){
			_this.mouseMove.call(_this,ev);
		};
		//	绑定鼠标抬起事件
		document.onmouseup = function(ev){
			_this.mouseUp.call(_this,ev);
		};
		
		
	},
	mouseMove:function(ev){
		ev = ev || event;
		this.currentEle.distancX = ev.clientX - this.currentEle.disX + this.currentEle.x;
		this.currentEle.distancY = ev.clientY - this.currentEle.disY + this.currentEle.y;
		this.currentEle.style.transform = "translate("+ this.currentEle.distancX +"px,"+ this.currentEle.distancY +"px)";
	},
	mouseUp:function(ev){
		this.currentEle.x = this.currentEle.distancX || 0;
		this.currentEle.y = this.currentEle.distancY || 0;
		console.log(this.currentEle.x);
		document.onmousemove = document.onmouseup = null;
		
	}
};
